package com.daniel.cloud.service;


import com.daniel.cloud.mapper.OrderMapper;
import com.daniel.cloud.order.entity.Order;
import com.daniel.cloud.user.entity.User;
import com.daniel.feign.clients.UserClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class OrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private UserClient userClient;

    public Order queryOrderById(Long orderId) {
        // 1.查询订单
        Order order = orderMapper.findById(orderId);
        // 2.查询用户信息
        User user = userClient.findById(order.getUserId());
        order.setUser(user);
        // 4.返回
        return order;
    }

    public String testBalanced() {
        // 1 请求地址
        String url = userClient.testLB();
        return url;
    }
}